package com.whjz.dcfs.ggts.struts.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.whjz.dcfs.ggts.dao.IDcfsTsclJbxxDAO;
import com.whjz.dcfs.ggts.model.DcfsTsclJbxx;
import com.whjz.dcfs.util.BaseAction;

public class JZTSCLAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	
	private DcfsTsclJbxx dcfsTsclJbxx;
	@Autowired
	private IDcfsTsclJbxxDAO dcfsTsclJbxxDAO;

	public void insertDcfsTsclJbxx() throws Exception{
		try{
			if(getHttpServletRequest().getParameter("ists").equals("1")){
				dcfsTsclJbxxDAO.insertDcfsTsclJbxx(dcfsTsclJbxx);
			}else if(getHttpServletRequest().getParameter("ists").equals("0")){
				dcfsTsclJbxxDAO.updateDcfsTsclJbxx(dcfsTsclJbxx);
			}
			getHttpServletResponse().getWriter().println("{success:'true',msg:'保存成功'}");
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void getDcfsTsclJbxxByPK() throws Exception{
		try{
			getHttpServletResponse().setCharacterEncoding("utf-8");
			List<DcfsTsclJbxx> list=dcfsTsclJbxxDAO.getDcfsTsclJbxxByPK(dcfsTsclJbxx);
			StringBuffer sb=new StringBuffer();
			if(list!=null&&list.size()>0){
				sb.append("{root:[");
				sb.append("tsbh:'"+(list.get(0).getTsbh()==null?"":list.get(0).getTsbh())+"',");
				sb.append("tsclr:'"+(list.get(0).getTsclr()==null?"":list.get(0).getTsclr())+"',");
				sb.append("tsclrgh:'"+(list.get(0).getTsclrgh()==null?"":list.get(0).getTsclrgh())+"',");
				sb.append("tsclsj:'"+(list.get(0).getTsclsj()==null?"":list.get(0).getTsclsj())+"',");
				sb.append("xccljg:'"+(list.get(0).getXccljg()==null?"":list.get(0).getXccljg())+"',");
				sb.append("xcms:'"+(list.get(0).getXcms()==null?"":list.get(0).getXcms())+"',");
				sb.append("]}");
			}
			getHttpServletResponse().getWriter().print(sb);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public DcfsTsclJbxx getDcfsTsclJbxx() {
		return dcfsTsclJbxx;
	}

	public void setDcfsTsclJbxx(DcfsTsclJbxx dcfsTsclJbxx) {
		this.dcfsTsclJbxx = dcfsTsclJbxx;
	}
	
	

}
